feat(plugins): allow message introspection#6353
Conversation
fdfa3c6 to
6140f6a
Compare
|
I refactored the access for message elements. If a property for a message element doesn't exist, we now return |
pajlada
left a comment
There was a problem hiding this comment.
just mini nit, otherwise looks good
|
@Mm2PL feel free to merge this in when you've taken a look / tested it / you're happy with it |
Mm2PL
left a comment
There was a problem hiding this comment.
Looks mostly good, just a couple nit picks. Please update the prose documentation to at least mention:
- that introspection is now possible
- that a concept of freezing a message exists
- liquid messages may be modified
| } | ||
| else | ||
| { | ||
| return visitOne<TReturn, Rest...>( |
There was a problem hiding this comment.
warning: use explicit 'this->' for member access [chatterino-explicit-this]
| return visitOne<TReturn, Rest...>( | |
| return this->visitOne<TReturn, Rest...>( |
| bool firstIteration = true; | ||
| for (Word &word : this->words_) | ||
| for (const auto &word : this->words_) | ||
| { |
There was a problem hiding this comment.
warning: c++11 range-loop might detach Qt container (QStringList) [clazy-range-loop-detach]
| { | |
| ; | |
| )std::as_const(this->words_) |
Continuation of #5754. This allows users to introspect messages (i.e. look at the elements they're made up of).
The fields of messages are modifiable. Plugins can also add/remove elements. To allow Lua access to elements, they are wrapped in a custom iterator that keeps a reference to the original message. The fields of elements are mostly static right now. But it would be possible to allow modification.
A future feature could allow plugins to clone messages, which would then be modifiable again.